(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.popup.reportCompanyViewController', reportCompanyViewController);
	reportCompanyViewController.$inject = [ '$scope', '$q', '$uibModalInstance', 'Constants', 'dialogsModule', 'gridService', 'modalService', 'layoutConfig', 'validatorConfig', 'authService','reportService'];
	function reportCompanyViewController($scope, $q, $uibModalInstance, Constants, dialogsModule, gridService, modalService, layoutConfig, validatorConfig, authService,reportService) {
		var ctrl = this, log = $scope.loggerFactory.getLogger("reportCompanyViewLookup");
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		ctrl.reportFormatsOptions = reportService.getReportFormatsOptions();
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['close'] || dialogsModule.btnCallback['close']() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		
		ctrl.init = function() {
			
			ctrl.reportCompanyView = {};
			if (ctrl.dialogsModule.params.companyRpt) {
				ctrl.reportCompanyView = ctrl.dialogsModule.params.companyRpt;// get params from parent page
			} else {
				ctrl.reportCompanyView = {};
			}
			reportService.getReportOptions().then(function(response) {
				ctrl.localeCodeOptions = response.local;
			});
			ctrl.reportViewParameterGridOptions = gridService.createInnerGridOptions($scope, ctrl.layoutConfig.formConfigs.reportParmsCfg.tableConfigs.table, rowSelectionChanged);
			ctrl.reportViewParameterGridOptions.data = 'vm.reportCompanyView.reportParms';
		};
		
		function rowSelectionChanged(eventRow, selectedRows) {
			ctrl.selectedParameters = selectedRows;
		}
		

	}
})(angular);
